package com.our.shop.front.customer.web;

import java.io.IOException;
import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.session.RowBounds;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.our.shop.front.customer.service.CustomerService;
import com.our.shop.system.base.model.SerialNumber;
import com.our.shop.system.util.PageList;


@Controller
public class CustomerController {
	private static final Logger logger = LoggerFactory.getLogger(CustomerController.class); 

	
	@Autowired
	CustomerService customerService;
	
	@RequestMapping(value = "regist", method = RequestMethod.GET)
	public void regist(HttpServletRequest request, HttpServletResponse response) throws IOException{
		logger.debug("debug++++++++++++++");
		logger.info("info++++++++++++++");
		PageList list = customerService.queryForPageList("SerialNumber_select", new HashMap<String, Object>(), new RowBounds(5, 10));
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/json");
		response.getWriter().write("负载均衡测试："+ list.getTotalPage());
		response.getWriter().write("XXXgetTotalSize: "+ list.getTotalSize());
		for(int i = 0 ;i < list.size() ;i ++) {
			response.getWriter().write("XXXinfo: "+((SerialNumber)list.get(i)).getId());
		}
	} 
}
